package org.ykh.service.web;

import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.ykh.service.web.filter.RequestWrapperFilter;


import java.util.Arrays;

/**
 * @author ykh
 */
@Configuration
public class RegisterConfig {

    @Bean
    public FilterRegistrationBean requestWrapperFilter() {
        final RequestWrapperFilter filter = new RequestWrapperFilter();
        final FilterRegistrationBean<RequestWrapperFilter> requestWrapperFilterFilterRegistrationBean =
                new FilterRegistrationBean<>(filter);
        requestWrapperFilterFilterRegistrationBean.setOrder(1);
        requestWrapperFilterFilterRegistrationBean.setUrlPatterns(Arrays.asList("/*"));
        return requestWrapperFilterFilterRegistrationBean;
    }
}
